﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 移除班次和补贴规则多对多 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysAttendanceShiftSubsidyRule");

            migrationBuilder.AddColumn<Guid>(
                name: "ShiftId",
                table: "SysAttendanceSubsidyRule",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_SysAttendanceSubsidyRule_ShiftId",
                table: "SysAttendanceSubsidyRule",
                column: "ShiftId");

            migrationBuilder.AddForeignKey(
                name: "FK_SysAttendanceSubsidyRule_SysAttendanceShift_ShiftId",
                table: "SysAttendanceSubsidyRule",
                column: "ShiftId",
                principalTable: "SysAttendanceShift",
                principalColumn: "ID");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysAttendanceSubsidyRule_SysAttendanceShift_ShiftId",
                table: "SysAttendanceSubsidyRule");

            migrationBuilder.DropIndex(
                name: "IX_SysAttendanceSubsidyRule_ShiftId",
                table: "SysAttendanceSubsidyRule");

            migrationBuilder.DropColumn(
                name: "ShiftId",
                table: "SysAttendanceSubsidyRule");

            migrationBuilder.CreateTable(
                name: "SysAttendanceShiftSubsidyRule",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SysAttendanceShiftId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    SysAttendanceSubsidyRuleId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysAttendanceShiftSubsidyRule", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysAttendanceShiftSubsidyRule_SysAttendanceShift_SysAttendanceShiftId",
                        column: x => x.SysAttendanceShiftId,
                        principalTable: "SysAttendanceShift",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysAttendanceShiftSubsidyRule_SysAttendanceSubsidyRule_SysAttendanceSubsidyRuleId",
                        column: x => x.SysAttendanceSubsidyRuleId,
                        principalTable: "SysAttendanceSubsidyRule",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysAttendanceShiftSubsidyRule_SysAttendanceShiftId",
                table: "SysAttendanceShiftSubsidyRule",
                column: "SysAttendanceShiftId");

            migrationBuilder.CreateIndex(
                name: "IX_SysAttendanceShiftSubsidyRule_SysAttendanceSubsidyRuleId",
                table: "SysAttendanceShiftSubsidyRule",
                column: "SysAttendanceSubsidyRuleId");
        }
    }
}
